package com.zzyy.study.controller;

import cn.hutool.core.date.DateTime;
import com.zzyy.study.annotations.IdempotentAnnotation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auther zzyy
 * @create 2024-12-28 16:53
 */
@RestController
@Slf4j
public class IdempotentController
{
    @PostMapping("/order")
    @IdempotentAnnotation(requestId = "orderId") // 假设orderId是从客户端传来的唯一标识订单请求的参数
    public String placeOrder(@RequestParam("orderId") String orderId)
    {
        // 业务处理逻辑
        return DateTime.now().toString();
    }
}
